package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/shop")
@Api(tags = "用戶端店鋪相關接口")
@Slf4j
public class ShopUserController {

    @Autowired
    private RedisTemplate redisTemplate;

    public static final String KEY = "SHOP_STATUS";

    /**
     * 獲取店鋪狀態
     * @return
     */
    @GetMapping("status")
    @ApiOperation("用戶获取店铺的状态")
    public Result<Integer> getStatus() {

        Integer status = (Integer)redisTemplate.opsForValue().get(KEY);

        log.info("獲得店鋪狀態為：{}", status == 1 ? "正營業": "已打樣");

        return  Result.success(status);
    }

}
// oO9oG47oIvrMiEALIQ-NN2gsVyww